<template>
  <el-dialog title="选择分组" :visible.sync="$attrs.visableIf" @close="handleCloseDialog" :close-on-click-modal="false" :close-on-press-escape="false" append-to-body width="700px">
    <el-form ref="form" :rules="rules" :model="form" label-width="120px">
      <el-form-item label="选择分组：" prop="name" class="fileUpload">
        <el-checkbox-group v-model="form.type">
          <el-checkbox :label="item.value" name="type" v-for="(item, index) in groupList" :key="index">
            <span>{{ item.label }}</span>
          </el-checkbox>
        </el-checkbox-group>
      </el-form-item>
    </el-form>
    <div class="footer-btn" slot="footer">
      <el-button type="primary" @click="handleCloseDialog">取消</el-button>
      <el-button @click="onSubmit('form')">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: 'chooseGroup',
  components: {
  },
  data() {
    return {
      form: {
        type: [],//分组集合
      },
      groupList:[
        {value:'1',label:'第一组'},
        {value:'2',label:'第二组'},
        {value:'3',label:'第三组'},
      ],
      rules: {
        'chooseGroup': [
          {required: true, message: '请选择分组', trigger: 'change'}
        ],

      },
    }
  },
  created() {
  },
  mounted() {
  },
  watch: {},
  methods: {
    onSubmit(formName) {
      //提交的代码
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log('提交表单');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    handleCloseDialog() {
      this.$emit('update:visableIf', false);
      this.$emit('handleQuery');
    }
  }
}
</script>

<style scoped lang="scss">
.footer-btn {
  display: flex;
  justify-content: flex-end;
}

.item-li {
  padding: 16px;
  background: #f7f7f7;
  border-radius: 2px;

  .el-radio-group {
    margin-bottom: 10px;
  }
}

::v-deep .el-dialog__body {
  overflow-y: auto;
  min-height: 300px;
  max-height: 600px;

  .el-form-item {
    border: none !important;

    .el-form-item__label {
      padding-bottom: 0px
    }

    .item-big {
      display: flex;

      .el-button--medium {
        padding: 0px 10px;
        margin-left: 20px;
      }
    }
  }
}
.fileUpload {
  position: relative;
  .downFile {
    position: absolute;
    left:100px;
    top: 0px;
    color: #3070ff;
  }
}
</style>
